Start To Code From Here¶

Import Libraries¶

In [1]:
import matplotlib.pyplot as plt
import plotly.graph_objects as go
import numpy as np
from IPython.display import display, Markdown, Latex, Image
import pandas as pd

We are going to load the image first and then will display the image¶

In [2]:
# Load the image
image_path = 'image.jpg'
image = plt.imread(image_path)

# Display the image using Matplotlib
plt.imshow(image)
plt.axis('off')
plt.title('Image')
plt.show()

Creating table of pixel value and its frequency of an image above¶

Students Marks
Student 1 Mark 1
Student 2 Mark 2
Student 3 Mark 3
In [3]:
students = ["John", "Emma", "Michael", "Sophia", "Daniel", "Olivia", "David", "Isabella", "Matthew", "Emily"]
marks = [85, 92, 78, 95, 88, 90, 82, 93, 87, 91]


# Create a table using Plotly
table = go.Table(
    header=dict(values=['Students', 'Marks'], fill_color='green'),
    cells=dict(values=[students, marks])
)

layout = go.Layout(
    title='Student Marks Table',
    width=500
)

fig = go.Figure(data=[table], layout=layout)

fig.show()

$$RMSE = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_m)^2} $$

- yi is data value of a featrure

- ym is mean of all values given in feature

Histogram of the image using matplotlib of the image data using plotly¶

here I have generated random data using numpy to generate data values representing some normal distribution.

In [4]:
# Generate random data
data = np.random.normal(0, 200, 200000)
# Create a histogram of pixel intensities using Matplotlib
histogram, bins = np.histogram(data.flatten(), bins=256, range=[0, 256])
In [5]:
plt.hist(data, bins,color='purple')
Out[5]:
(array([372., 392., 405., 374., 420., 370., 422., 421., 407., 414., 414.,
        410., 411., 408., 407., 393., 415., 389., 388., 423., 409., 368.,
        399., 451., 417., 402., 396., 382., 360., 363., 367., 394., 401.,
        399., 383., 387., 373., 399., 406., 403., 378., 417., 358., 386.,
        381., 375., 409., 420., 369., 418., 385., 392., 411., 390., 402.,
        343., 365., 349., 354., 376., 348., 385., 381., 379., 368., 376.,
        368., 376., 354., 410., 375., 378., 398., 385., 356., 385., 399.,
        404., 387., 360., 365., 360., 409., 377., 366., 367., 367., 373.,
        331., 387., 347., 403., 382., 369., 335., 355., 371., 384., 370.,
        369., 336., 382., 377., 335., 413., 328., 357., 386., 353., 370.,
        315., 333., 324., 324., 340., 333., 326., 359., 360., 345., 346.,
        332., 320., 309., 299., 315., 303., 319., 347., 333., 326., 298.,
        349., 327., 333., 307., 318., 305., 337., 314., 312., 318., 290.,
        274., 316., 275., 308., 307., 306., 320., 307., 295., 285., 314.,
        297., 304., 299., 301., 314., 268., 297., 299., 273., 269., 271.,
        267., 288., 292., 282., 288., 259., 283., 294., 258., 285., 275.,
        264., 265., 257., 275., 292., 241., 252., 258., 272., 264., 261.,
        241., 256., 239., 228., 273., 243., 267., 245., 257., 277., 234.,
        259., 245., 234., 260., 250., 243., 231., 225., 244., 218., 217.,
        210., 246., 232., 221., 244., 226., 222., 215., 240., 248., 210.,
        223., 212., 227., 202., 227., 215., 200., 188., 218., 209., 203.,
        198., 202., 205., 202., 187., 200., 206., 198., 188., 199., 205.,
        194., 210., 175., 201., 190., 192., 187., 183., 203., 182., 157.,
        202., 184., 193.]),
 array([  0.,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.,
         11.,  12.,  13.,  14.,  15.,  16.,  17.,  18.,  19.,  20.,  21.,
         22.,  23.,  24.,  25.,  26.,  27.,  28.,  29.,  30.,  31.,  32.,
         33.,  34.,  35.,  36.,  37.,  38.,  39.,  40.,  41.,  42.,  43.,
         44.,  45.,  46.,  47.,  48.,  49.,  50.,  51.,  52.,  53.,  54.,
         55.,  56.,  57.,  58.,  59.,  60.,  61.,  62.,  63.,  64.,  65.,
         66.,  67.,  68.,  69.,  70.,  71.,  72.,  73.,  74.,  75.,  76.,
         77.,  78.,  79.,  80.,  81.,  82.,  83.,  84.,  85.,  86.,  87.,
         88.,  89.,  90.,  91.,  92.,  93.,  94.,  95.,  96.,  97.,  98.,
         99., 100., 101., 102., 103., 104., 105., 106., 107., 108., 109.,
        110., 111., 112., 113., 114., 115., 116., 117., 118., 119., 120.,
        121., 122., 123., 124., 125., 126., 127., 128., 129., 130., 131.,
        132., 133., 134., 135., 136., 137., 138., 139., 140., 141., 142.,
        143., 144., 145., 146., 147., 148., 149., 150., 151., 152., 153.,
        154., 155., 156., 157., 158., 159., 160., 161., 162., 163., 164.,
        165., 166., 167., 168., 169., 170., 171., 172., 173., 174., 175.,
        176., 177., 178., 179., 180., 181., 182., 183., 184., 185., 186.,
        187., 188., 189., 190., 191., 192., 193., 194., 195., 196., 197.,
        198., 199., 200., 201., 202., 203., 204., 205., 206., 207., 208.,
        209., 210., 211., 212., 213., 214., 215., 216., 217., 218., 219.,
        220., 221., 222., 223., 224., 225., 226., 227., 228., 229., 230.,
        231., 232., 233., 234., 235., 236., 237., 238., 239., 240., 241.,
        242., 243., 244., 245., 246., 247., 248., 249., 250., 251., 252.,
        253., 254., 255., 256.]),
 <BarContainer object of 256 artists>)
In [6]:
# # Create a scatter graph of the histogram using Plotly
fig = go.Figure(
    data=[
        go.Scatter(x=bins[:-1], y=histogram)
    ]
)
fig.update_layout(
    title='Scatter graph of Pixel Intensities', 
    xaxis=dict(title='Pixel Intensity'),
    yaxis=dict(title='Frequency'),
)

fig.show()